package com.example.student.controller;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.example.student.utils.JSONResult;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletResponse;
import javax.xml.ws.RequestWrapper;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

@Controller
public class IndexController {

    @RequestMapping(value="/query_href",produces = "application/json;charset=utf-8")
    @CrossOrigin(origins = "*")
    public void index(HttpServletResponse response) throws IOException {
        response.setHeader("Content-type", "text/html; charset=utf-8");
        JSONObject dataMap = new JSONObject();
        dataMap.put("config","百度");
        dataMap.put("data","http://www.baidu.com");
        JSONArray al = new JSONArray();
        al.add(dataMap);
        JSONObject dataMap1 = new JSONObject();
        dataMap1.put("config","搜狐");
        dataMap1.put("data","http://www.sohu.com");
        al.add(dataMap1);
        JSONObject obj = new JSONObject();
        obj.put("data",al);
        response.getWriter().write(String.valueOf(obj));
    }
}
